package com.example.pclimb.ui.guides;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.example.pclimb.model.TravelGuide;
import com.example.pclimb.repository.TravelGuideRepository;

import java.util.List;

public class GuidesViewModel extends ViewModel {

    private final MutableLiveData<List<TravelGuide>> guides = new MutableLiveData<>();
    private final MutableLiveData<Boolean> isLoading = new MutableLiveData<>(false);
    private TravelGuideRepository repository;

    public GuidesViewModel() {
        // TODO: 初始化repository
        // repository = new TravelGuideRepository();
    }

    public LiveData<List<TravelGuide>> getGuides() {
        return guides;
    }

    public LiveData<Boolean> getIsLoading() {
        return isLoading;
    }

    public void loadGuides() {
        isLoading.setValue(true);
        // TODO: 从repository加载旅行指南数据
        // repository.getAllGuides(guides -> {
        //     this.guides.setValue(guides);
        //     isLoading.setValue(false);
        // });
    }

    public void addGuide(TravelGuide guide) {
        // TODO: 添加新的旅行指南
        // repository.addGuide(guide, () -> loadGuides());
    }

    public void deleteGuide(long guideId) {
        // TODO: 删除旅行指南
        // repository.deleteGuide(guideId, () -> loadGuides());
    }
} 